﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
  <link href="${ctx.resource}/css/shiftform.css" rel="stylesheet">
  <link href="${ctx.resource}/css/select2.css" rel="stylesheet">
  <link href="${ctx.resource}/css/select2-bootstrap.css" rel="stylesheet">
  <link href="${ctx.resource}/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
  
  <title></title>

</head>

<script type="text/javascript">

</script>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>

  <%@ include file="/WEB-INF/include/menu.jsp"%>

  <div class="container main-content">

    <div class="panel panel-default beast-panel beast-panel-layout">

      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/customers">用户管理</a></li>
          <li class="active">用户提现</li>
        </ol>
      </div>

      <div class="panel-body">

        <div class="col-xs-2 beast-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>

        <div class="col-xs-10 beast-panel-layout-right">

          <div class="beast-breadcrumb-wrapper">
            <div class="beast-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire" title="用户提现"></i>&nbsp;&nbsp;<span>用户提现&nbsp;-&nbsp;提现列表</span></h2>
            </div>
          </div>
          
          <div class="beast-breadcrumb-wrapper clearfix">
              
            <ul class="nav nav-pills beast-breadcrumb-nav">
              <li class="pull-left ${(status eq 'AUDITING') or (empty status)  ? 'active': ''}"><a href="${ctx.host}/customer-withdrawals?status=AUDITING">待审核</a></li>
              <li class="pull-left ${status eq 'TRANSFERING' ? 'active': ''}"><a href="${ctx.host}/customer-withdrawals?status=TRANSFERING">待打款</a></li>
              <li class="pull-left ${status eq 'EXPORTED' ? 'active': ''}"><a href="${ctx.host}/customer-withdrawals?status=EXPORTED">已导出报表</a></li>
              <li class="pull-left ${status eq 'SUCCESS' ? 'active': ''}"><a href="${ctx.host}/customer-withdrawals?status=SUCCESS">已完成</a></li>
            </ul>
            
          </div>
          <c:if test="${status eq 'EXPORTED'}">
            <div class="beast-toolbar-wrapper top-margin-20 clearfix">
		          <div class="btn-group pull-right">
		           <button id="confirm-pay" type="button" class="btn btn-default demo2do-btn btn-shadow btn-shadow-default" data-toggle="modal" data-target="#transfer">确认打款</button>
		          </div>
		        </div>
	          <div class="modal fade" id="transfer" tabindex="-1" role="dialog" aria-labelledby="transferLabel">
                <div class="modal-dialog demo2do-modal-dialog" role="document">	               
				           <div class="modal-content">

									    <div class="modal-header beast-breadcrumb no-bottom-border clearfix">
									
									      <h2><i class="glyphicon glyphicon-fire" title="确认打款"></i>&nbsp;&nbsp;<span>确认打款</span></h2>
									
									      <button type="button" class="close" data-dismiss="modal">&times;</button>
									
									    </div>
									
									    <form id="myform" class="form-horizontal" method="POST" action="${ctx.host}/customer-withdrawals/transfer"><%-- data-redirect="${ctx.host}/customer-withdrawals?status=SUCCESS" --%>
									
									      <input type="hidden" name="withdrawalIds">
									
									      <div class="modal-body">
									      
									        <p class="confirm">
									          <i class="glyphicon glyphicon-flash glyphicon-position-fix-2"></i>&nbsp;&nbsp;是否确认已选中部分的打款操作？
									        </p>
									        
									      </div>
									
									      <div class="modal-footer">
									        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success demo2do-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
									        <button type="button" class="btn btn-default btn-shadow btn-shadow-default demo2do-btn" data-dismiss="modal">取消</button>
									      </div>
									
									    </form>
									
									  </div>
			          </div>	 
            </div>
            
          </c:if>
          <c:if test="${status eq 'TRANSFERING'}">
            <div class="beast-toolbar-wrapper top-margin-20 clearfix">
	            <div class="btn-group pull-right">
	             <button id="confirm-export" type="button" class="btn btn-default demo2do-btn btn-shadow btn-shadow-default" data-toggle="modal"data-target="#export">确认已导出报表</button>
	            </div>
	            <div class="btn-group pull-right">
	             <button id="confirm-export" type="button" class="btn btn-default demo2do-btn btn-shadow btn-shadow-default" onclick="window.location='${ctx.host}/customer-withdrawals/export'">导出Excel</button>
	            </div>
	          </div>
	          
	          <div class="modal fade" id="export" tabindex="-1" role="dialog" aria-labelledby="exportLabel">
                <div class="modal-dialog demo2do-modal-dialog" role="document">                
                   <div class="modal-content">

                      <div class="modal-header beast-breadcrumb no-bottom-border clearfix">
                  
                        <h2><i class="glyphicon glyphicon-fire" title="确认已导出报表"></i>&nbsp;&nbsp;<span>确认已导出报表</span></h2>
                  
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                  
                      </div>
                  
                      <form class="form-horizontal" method="POST" action="${ctx.host}/customer-withdrawals/export" data-redirect="${ctx.host}/customer-withdrawals?status=EXPORTED">
                        
                        <input type="hidden" name="_method" value="PATCH" >
                        <div class="modal-body">
                        
                          <p class="confirm">
                            <i class="glyphicon glyphicon-flash glyphicon-position-fix-2"></i>&nbsp;&nbsp;是否确认已导出报表？
                          </p>
                          
                        </div>
                  
                        <div class="modal-footer">
                          <button type="submit" class="btn btn-success btn-shadow btn-shadow-success demo2do-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
                          <button type="button" class="btn btn-default btn-shadow btn-shadow-default demo2do-btn" data-dismiss="modal">取消</button>
                        </div>
                  
                      </form>
                  
                    </div>
                </div>   
            </div>
          </c:if>
          <table class="table table-striped table-hover demo2do-table bottom-margin-20">
            <thead>
              <tr>
                <c:if test="${status eq 'EXPORTED'}">
                  <th>
                     	<input style="position: absolute;left: 33px;" id="selectAll" type="checkbox">&nbsp;<font style="position: absolute;left: 48px;">全选</font>
                  </th>
                </c:if>
                <th>手机号</th>
                <th>圈圈族账号</th>
                <c:if test="${(status eq 'TRANSFERING') or (status eq 'EXPORTED') }">
                  <th>支付宝账号</th>
                  <th>支付宝账户名</th>
                </c:if>
                <th>提现金额</th>
                <th>提现方式</th>
                <th>申请时间</th>
                <c:if test="${(status eq 'AUDITING') or (empty status)}">
                  <th>操作</th>
                </c:if>
              </tr>
            </thead>
            <tbody>
	            <c:forEach var="withdrawal" items="${withdrawals}">
	              
                <tr>                 
                  <c:if test="${status eq 'EXPORTED'}">
                   <td><input class='withdrawalSelect' name="withdrawalId" type="checkbox" value="${withdrawal.id }"></td> 
                  </c:if>
                  <td>${withdrawal.customer.mobile}</td>
                  <td>${withdrawal.customer.code}</td>
                  <c:if test="${(status eq 'TRANSFERING') or (status eq 'EXPORTED') }">
                    <td>${withdrawal.account}</td>
                    <td>${withdrawal.accountName}</td>
                  </c:if>
                  <td>${withdrawal.balance/100}元</td>
                  <td><span class="label label-${withdrawal.type.css}">${withdrawal.type.description}</span></td>  
                  <td><fmt:formatDate value="${withdrawal.createTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>                  
                  <c:if test="${(status eq 'AUDITING') or (empty status)}">
	                  <td>
	                    <a href="${ctx.host}/customer-withdrawals/${withdrawal.id}" data-target="#" data-toggle="modal" class="hover-no-text-decoration" title="详情">详情</a>
	                    <a href="${ctx.host}/customer-withdrawals/${withdrawal.id}/audit" class="hover-no-text-decoration text-danger" data-toggle="modal" data-target="#" title="审核">审核</a>
	                  </td>
	                </c:if>
                </tr> 
                 
	            </c:forEach>  
            </tbody>
          </table>
          <c:choose>
            <c:when test="${not empty queryString}">
              <jsp:include page="/WEB-INF/include/page.jsp">
                <jsp:param name="url" value="customer-withdrawals/search" /> 
                <jsp:param name="queryString" value="${queryString}" />
              </jsp:include>
            </c:when>
            <c:otherwise>
              <jsp:include page="/WEB-INF/include/page.jsp">
                <jsp:param name="url" value="customer-withdrawals" />
              </jsp:include>
            </c:otherwise>
          </c:choose>     
        </div>

      </div>

    </div>

  </div>

  <%@ include file="/WEB-INF/include/footer.jsp"%>
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <script src="${ctx.resource}/js/shiftform.js"></script>
  <script src="${ctx.resource}/js/select2.min.js"></script>
  <script src="${ctx.resource}/js/select2_locale_zh-CN.js"></script>
  <script src="${ctx.resource}/js/bootstrap-datetimepicker.js"></script>
  <script src="${ctx.resource}/js/bootstrap-datetimepicker.zh-CN.js"></script>
  

</body>
<script type="text/javascript">
    $('#transfer').on('show.bs.modal', function (event) {
      var button = $(event.relatedTarget);
    });
    $('#export').on('show.bs.modal', function (event) {
      var button = $(event.relatedTarget);
    });
</script>
<script type="text/javascript">
	
$(document).ready(function(){
	
	   $("#selectAll").on('click', function(event){
		   
		   if($(this).prop('checked')) {
			   $("input.withdrawalSelect").each(function(){
	         $(this).prop('checked', true);
	       });
		   }else {
			   $("input.withdrawalSelect").each(function(){
	         $(this).prop('checked', false);
	       });
		   }
		   changeValue();
	   });
	   
	   $("input.withdrawalSelect").on('click', function(event){
		   changeValue();
	   });
	  
	   var changeValue = function(data) {
		   
		   var data = new Array();
		   
		   $("input.withdrawalSelect").each(function(){
         if($(this).prop('checked')) {
        	 data.push($(this).val());
         }
       });
       $("input[name='withdrawalIds']").val(data);
	   };
	   $('form').shiftform();
	
});   
</script>

</html>
